﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;

namespace TSOL.Helpers
{
    public static class EParser
    {
        public static T Parse<T>(string value)
        {
            try { return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(value); }
            catch { return default(T); };
        }
        public static T Parse<T>(object value)
        {
            try { return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertTo(value, typeof(T)); }
            catch { return default(T); };
        }
    }
}